package com.example.tms.bean;

import com.alibaba.fastjson.annotation.JSONField;
import com.example.tms.tools.GlobalParam;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.security.NoSuchAlgorithmException;
import java.util.Date;

/**
 * 用户信息
 */
@Table(name = "user_info")
@Entity
@DynamicInsert
@DynamicUpdate
public class UserInfo {
    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    private String yhid;
    private String yhm;
    private String zsxm;
    private String sjh;
    private String bumenid;
    private String mima;
    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    private Date zcsj;
    private Boolean sfcz;
    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    private Date lasttime;
    @Transient
    private String oldpsw;
    private String shzt;
    private String yuanyin;
    private String headpic;

    @Override
    public String toString() {
        return "UserInfo{" +
                "yhid='" + yhid + '\'' +
                ", yhm='" + yhm + '\'' +
                ", zsxm='" + zsxm + '\'' +
                ", sjh='" + sjh + '\'' +
                ", bumenid='" + bumenid + '\'' +
                ", mima='" + mima + '\'' +
                ", zcsj=" + zcsj +
                ", sfcz=" + sfcz +
                ", lasttime=" + lasttime +
                ", oldpsw='" + oldpsw + '\'' +
                ", shzt='" + shzt + '\'' +
                ", yuanyin='" + yuanyin + '\'' +
                ", headpic='" + headpic + '\'' +
                '}';
    }

    public String getHeadpic() {
        return headpic;
    }

    public void setHeadpic(String headpic) {
        this.headpic = headpic;
    }

    public String getShzt() {
        return shzt;
    }

    public void setShzt(String shzt) {
        this.shzt = shzt;
    }

    public String getOldpsw() {
        return oldpsw;
    }

    public void setOldpsw(String oldpsw) {
        this.oldpsw = oldpsw;
    }

    public Date getLasttime() {
        return lasttime;
    }

    public void setLasttime(Date lasttime) {
        this.lasttime = lasttime;
    }

    public String getYhid() {
        return yhid;
    }

    public void setYhid(String yhid) {
        this.yhid = yhid;
    }

    public String getYhm() {
        return yhm;
    }

    public void setYhm(String yhm) {
        this.yhm = yhm;
    }

    public String getZsxm() {
        return zsxm;
    }

    public void setZsxm(String zsxm) {
        this.zsxm = zsxm;
    }

    public String getSjh() {
        return sjh;
    }

    public void setSjh(String sjh) {
        this.sjh = sjh;
    }

    public String getBumenid() {
        return bumenid;
    }

    public void setBumenid(String bumenid) {
        this.bumenid = bumenid;
    }

    public String getMima() {
        return mima;
    }

    public void setMima(String mima) {
        this.mima = mima;
    }

    public Boolean getSfcz() {
        return sfcz;
    }

    public void setSfcz(Boolean sfcz) {
        this.sfcz = sfcz;
    }

    public Date getZcsj() {
        return zcsj;
    }

    public void setZcsj(Date zcsj) {
        this.zcsj = zcsj;
    }

    public String getYuanyin() {
        return yuanyin;
    }

    public void setYuanyin(String yuanyin) {
        this.yuanyin = yuanyin;
    }

    public UserInfo(){}

    public UserInfo(DriverApp driverApp) throws NoSuchAlgorithmException {
        this.yhm=driverApp.getSfzh().toUpperCase();
        String mima = GlobalParam.getMD5(driverApp.getMima());
        this.mima = mima;
        this.shzt = "未审核";
        this.sjh =driverApp.getSjhm();
        this.zsxm = driverApp.getXingming();
        this.bumenid = "";
        this.zcsj = driverApp.getLasttime();
        this.sfcz = true;
        this.lasttime = driverApp.getLasttime();
    }

    }
